<?php

/**
 * Description of Exposure_orderController
 *
 * @author wml
 */

namespace Home\Controller;

use Think\Controller;

class ExposureOrderController extends Controller {

    public function exposureList() {

        $result = D("exposure_order")->getExposureOrder("user_id=" . session("user.id"));
        $this->assign("dataResult", $result['comList']);
        $this->assign("page", $result['page']);
        $this->display();
    }

    public function submitExposure() {
        $exposureModel = D("exposure_order");
        if (IS_POST) {

            //审核已过的信息无法修改    
            if (!empty($_POST['id'])) {
                $exposureInfo = $exposureModel->getDataById($_POST['id'], "id,is_apply");
                if ($exposureInfo['is_apply'] != 0) {
                    $this->error("只有未审核信息才能修改");
                }
            } else {
                $result = $exposureModel->editData(I("post."));
                if (!$result) {
                    $this->error($exposureModel->getError());
                } else {
                    $this->success();
                }
            }
        } else {
            $datalist = D("Admin/ExposurePackage")->getExposurePackage("id,package_content,exposure_num,price");
            $this->assign("datalist", $datalist);
            $this->display();
        }
    }
        
    /*
     * 查看曝光的详情
     * csb
     */
    public function exposureInfo() {
        $exposure = D('exposure_order');
        $id = intval(I('post.id'));
        if (!$id) {
            $arr['status'] = 100;
            $arr['info'] = "缺少参数，请刷新重试";
        } else {
            
            $relust = $exposure->getDataById("id=" . $id);
            $relust['package_name']  =   M("exposure_package")->where(array('id'=>$relust['package_id']))->getField("package_name");
            $relust['status']  =  $relust['status'] == 1 ? "已审核" :$relust['status'] == 2 ? "审核失败" : "未审核" ;
            $relust['imgs'] =is_array(explode(",",$relust['exposure_imgs']))?explode(",",$relust['exposure_imgs']):$relust['exposure_imgs'];
            if (count($relust) < 0) {
                $arr['status'] = 100;
                $arr['info'] = "查询失败，请刷新重试";
            } else {
                $arr['status'] = 200;
                $arr['info'] = $relust;
            }
        }
        $this->ajaxReturn($arr);
    }
}

?>
